<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>formdata</title>
</head>
<body>
    <form action="" id="myForm" name="myForm">
        <div>
            <label for="username">用户名：</label>
            <input type="text" required id="username" name="username">
        </div>
        <div>
            <label for="useracc">账号：</label>
            <input type="text" id="useracc" name="useracc">
        </div>
        <div>
            <label for="userfile">上传文件：</label>
            <input type="file" id="userfile" name="userfile">
        </div>
        <input type="submit" value="Submit!">
        <input type="email" id="email">
    </form>
    <script>
        var myForm = document.getElementById("myForm")
        var formData = new FormData(myForm)
        formData.get("username")
        formData.set('username', "张三")
        console.log(formData.get("username"))

        var email = document.getElementById("email")
        email.oninvalid = e=>{
            event.target.setCustomValidity("邮件格式不对")
        }
        console.dir(email)
    </script>
</body>
</html>